package com.ys.controller;

import com.alibaba.fastjson.support.spring.annotation.ResponseJSONP;
import com.ys.mapper.DrguoqiMapper;
import com.ys.mapper.DruMapper;
import com.ys.pojo.*;
import com.ys.service.CgoderService;
import com.ys.service.CgoqualityService;
import com.ys.vo.ResultVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class Tuihuo {
    @Resource
    private DrguoqiMapper drguoqiMapper;
    @Resource
    private DruMapper druMapper;

    @RequestMapping(value = "/chaxunguoqi", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ResultVo chaxunguoqi(){
        ResultVo resultVo = new ResultVo();
        resultVo.setObj(drguoqiMapper.listDrguoqi());
        return  resultVo;
    }



    @RequestMapping(value = "/xunigouwussssss", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ResultVo add(@RequestBody Drguoqi drguoqi){
        ResultVo resultVo = new ResultVo();
        Dru dru = new Dru();
        dru.setDrugsid(drguoqi.getDrugsid());
        dru.setDrugsName(drguoqi.getDrugsName());
        dru.setNumberNumber(drguoqi.getNumberNumber());
        dru.setDanjia(drguoqi.getPrice());
        dru.setSpecifications(drguoqi.getSpecifications());
        druMapper.add(dru);
        return resultVo;
    }

    @Resource
    private CgoqualityService cgoqualityService ;
    @Resource
    private CgoderService cgoderService;

//    @RequestMapping("/zhijianyuanjiancesasdad")
//    @ResponseBody
//    public ResultVo zhijianyuanjiance(@RequestBody Cgoquality cgoquality){
//        ResultVo resultVo = new ResultVo();
//        Session session = SecurityUtils.getSubject().getSession();
//        Administrators administrators = (Administrators) session.getAttribute("objs");
//        cgoquality.setQualPer(administrators.getId());
////        if(cgoquality.getQualState()==1){
////            cgoderService.updscomment(String.valueOf(cgoquality.getQualState()));
////        }
//        if(cgoqualityService.addsinsert(cgoquality)>0){
//            cgoderService.updscdingdanStar();
////            cgoderService.updsdate(String.valueOf(cgoquality.getCgoId()));
////            cgoderService.updscomment(String.valueOf(cgoquality.getCgoId()));
//            resultVo.setMsg("检测成功!");
//        }else {
//            resultVo.setMsg("检测失败!");
//        }
//        return resultVo;
//    }
}
